mkdir data
{
"config": {
"chainId": xxxx(修改任意數字,不能為0),
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc": {},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x20000"(可修改難度值),
"extraData" : "",
"gasLimit": "0x2fefd8",
"nonce": "0x0000000000000042",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00"
}
geth --datadir "./data" --networkid 31415926 --rpc --rpccorsdomain "*" init ./genesis.json
geth –datadir "./data" --networkid 31415926 --rpc --rpccorsdomain "*" --nodiscover console 2>>xxx.log
便會進入到geth控制介面
>personal.newAccount("密碼")
創建成功將返回賬戶的地址
>user1=eth.accounts[0]
>eth.accounts
OR
>web3.eth.getAccounts
>eth.getBalance("賬戶地址")
OR
>eth.getBalance(user1)
>miner.start(1) 表1個線程挖礦
>miner.stop()
>miner.setEtherbase(eth.accounts[1])
true
tail -f xxx.log
>eth.getBalance(eth.accounts[0])
>eth.blockNumber
查看想看的區塊:
>eth.blockNumber(N)
>personal.unlockAccount(eth.accounts[0],"PWD",0)
true
0 代表長時間解鎖(單位為毫秒)。
>eth.sendTransaction({from:eth.accounts[0],to:eth.accounts[1],value:web3.toWei(要轉的錢數,'ether')})
>eth.getBalance(eth.accounts[1])
100000000000000000
>web3.fromWei(eth.getBalance(eth.accounts[0]), 'ether')
1 ether = 10^18 wei
文章另會分享在stars blog中,歡迎一起交流。